package com.talkweb.platform.commonapi.utils;

import java.util.HashMap;

/**
 * 存储本地线和变更内容
 * 
 * @author lzy
 *
 */
public class ThreadLocalHelper
{
    private static ThreadLocal<HashMap<String, Object>> threadLocalMap = new ThreadLocal<HashMap<String, Object>>();
    
    public static void put(String key, Object value)
    {
        HashMap<String, Object> map = threadLocalMap.get();
        if (null == map)
        {
            map = new HashMap<String, Object>();
            threadLocalMap.set(map);
        }
        map.put(key, value);
    }
    
    public static Object getValue(String key)
    {
        return null == threadLocalMap.get() ? null : threadLocalMap.get().get(key);
    }
    
    /*public static HashMap<String, Object> get(String key)
    {
        return threadLocalMap.get();
    }*/
    
    public static void clearValue(String key){
        HashMap<String, Object> map = threadLocalMap.get();
        if(null != map){
            map.remove(key);
        }
    }
}
